package org.example.myleet.p1232;

public class Solution {
    /**
     * 0 ms
     */
    public boolean checkStraightLine(int[][] coordinates) {
        int dx = coordinates[1][0] - coordinates[0][0];
        int dy = coordinates[1][1] - coordinates[0][1];
        if (dx == 0) {
            for (int[] coordinate : coordinates) {
                if (coordinate[0] != coordinates[0][0]) {
                    return false;
                }
            }
            return true;
        }
        double deltaX = dx;
        double deltaY = dy;
        double k = deltaY / deltaX;
        for (int i=2; i<coordinates.length; i++) {
            deltaX = coordinates[i][0] - coordinates[i-1][0];
            if (deltaX == 0) {
                return false;
            }
            deltaY = coordinates[i][1] - coordinates[i-1][1];
            if (k != (deltaY / deltaX)) {
                return false;
            }
        }
        return true;
    }
}
